﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class xiugai : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["userid"] == null)
            {
                Response.Write("<script type=\"text/javascript\">top.location.href=\"login.aspx\";</script>");
            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string str = "SELECT password FROM  opeartorman where no='" + Session["userid"].ToString() + "';";
        DataSet ds = new DataSet();
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["medical"].ConnectionString);
        con.Open();
        SqlDataAdapter sda = new SqlDataAdapter(str, con);
        sda.Fill(ds);
        if ((TextBox3.Text.ToString()) != (ds.Tables[0].Rows[0][0].ToString()))
        {
            Response.Write("<script>alert('原密码输入错误')</script>");
        }
        else
        {
            Change();
        }
    }
    protected void Change()
    {
        string str = "update opeartorman set password='" + TextBox2.Text.ToString() + "' where no='" + Session["userid"].ToString() + "';";
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["medical"].ConnectionString);
        con.Open();
        SqlCommand cmd = new SqlCommand(str, con);
        cmd.ExecuteNonQuery();
        con.Close();
        Response.Write("<script>alert('恭喜，密码修改成功')</script>");
    }       
}
